package com.yxb.application.service.impl;

import java.util.List;

import com.yxb.profile.domain.TeacherProfile;
import com.yxb.profile.mapper.TeacherProfileMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yxb.application.mapper.TeacherApplicationMapper;
import com.yxb.application.domain.TeacherApplication;
import com.yxb.application.service.ITeacherApplicationService;

/**
 * 家教申请Service业务层处理
 * 
 * @author 林德炫
 * @date 2025-03-28
 */
@Service
public class TeacherApplicationServiceImpl implements ITeacherApplicationService 
{
    @Autowired
    private TeacherApplicationMapper teacherApplicationMapper;

    @Autowired
    private TeacherProfileMapper teacherProfileMapper;

    /**
     * 查询家教申请
     * 
     * @param applicationId 家教申请主键
     * @return 家教申请
     */
    @Override
    public TeacherApplication selectTeacherApplicationByApplicationId(Long applicationId)
    {
        return teacherApplicationMapper.selectTeacherApplicationByApplicationId(applicationId);
    }

    /**
     * 查询家教申请列表
     * 
     * @param teacherApplication 家教申请
     * @return 家教申请
     */
    @Override
    public List<TeacherApplication> selectTeacherApplicationList(TeacherApplication teacherApplication)
    {
        return teacherApplicationMapper.selectTeacherApplicationList(teacherApplication);
    }

    /**
     * 新增家教申请
     * 
     * @param teacherApplication 家教申请
     * @return 结果
     */
    @Override
    public int insertTeacherApplication(TeacherApplication teacherApplication)
    {
//        System.out.println("666666666666666666666666666666666666666666666666666");
//        下面的实现逻辑应该没有必要，先注释了
//        if (teacherApplication.getStatus().equals("approved")){
//            TeacherProfile teacherProfile = new TeacherProfile();
//            System.out.println("1111111111111111111111111111有没有获取到id"+teacherApplication.getuserId());
//            teacherProfile.setuserId(teacherApplication.getuserId());
//            teacherProfile.setTeacherName(teacherApplication.getTeacherName());
//            teacherProfile.setGender(teacherApplication.getGender());
//            teacherProfile.setAge(teacherApplication.getAge().intValue());
//            teacherProfile.setEducation(teacherApplication.getEducation());
//            teacherProfile.setCertification(teacherApplication.getCertification());
//            teacherProfile.setavatar(teacherApplication.getavatar());
//            teacherProfile.setPhoneNumber(teacherApplication.getPhoneNumber());
//            teacherProfile.setEmail(teacherApplication.getEmail());
//            teacherProfile.setIntroduction(teacherApplication.getIntroduction());
//            teacherProfile.setMajor(teacherApplication.getMajor());
//            teacherProfile.setTeachingExp(teacherApplication.getTeachingExp());
//            teacherProfile.setSchool(teacherApplication.getSchool());
//            teacherProfile.setTeachingcategoryName(teacherApplication.getSubject());
//            teacherProfile.setHourlyRate(teacherApplication.getHourlyRate());
//            teacherProfileMapper.insertTeacherProfile(teacherProfile);
//        }
        return teacherApplicationMapper.insertTeacherApplication(teacherApplication);
    }

    /**
     * 修改家教申请
     * 
     * @param teacherApplication 家教申请
     * @return 结果
     */
    @Override
    public int updateTeacherApplication(TeacherApplication teacherApplication)
    {
        return teacherApplicationMapper.updateTeacherApplication(teacherApplication);
    }

    /**
     * 批量删除家教申请
     * 
     * @param applicationIds 需要删除的家教申请主键
     * @return 结果
     */
    @Override
    public int deleteTeacherApplicationByApplicationIds(Long[] applicationIds)
    {
        return teacherApplicationMapper.deleteTeacherApplicationByApplicationIds(applicationIds);
    }

    /**
     * 删除家教申请信息
     * 
     * @param applicationId 家教申请主键
     * @return 结果
     */
    @Override
    public int deleteTeacherApplicationByApplicationId(Long applicationId)
    {
        return teacherApplicationMapper.deleteTeacherApplicationByApplicationId(applicationId);
    }

    @Override
    public TeacherApplication getApplicationByUserId(Long userId) {
        return teacherApplicationMapper.getApplicationByUserId(userId);
    }

    @Override
    public int updateApplicationStatusByUserId(Long userId) {
        return teacherApplicationMapper.updateApplicationStatusByUserId(userId, "pending");
    }
}
